﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication17
{
    public partial class Form1 : Form
    {
        //HtmlDocument htmlDoc;
        public Form1()
        {
            InitializeComponent();
            monthCalendar1.Visible = false;
            TextBox textBox1 = new TextBox();
            this.Controls.Add(textBox1);
            this.textBox1.Click += new EventHandler(textBox1_Click);
        }
        private void textBox1_Click(object sender, EventArgs e)
        {
            monthCalendar1.Show();
        }

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            textBox1.Text = monthCalendar1.SelectionStart.ToString("dd/MM/yyyy");
            monthCalendar1.Visible = false;
        }
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //if (webBrowser1.Document != null)
            //{
            //    htmlDoc = webBrowser1.Document;
            //    htmlDoc.Click += htmlDoc_Click;
            //}
        }
        //private void htmlDoc_Click(object sender, HtmlElementEventArgs e)
        //{
        //    if (monthCalendar1.Visible)
        //    {
        //        monthCalendar1.Visible = !monthCalendar1.Visible;
        //    }
        //    e.ReturnValue = false;
        //}
        private void button1_Click(object sender, EventArgs e)
        {
            HtmlElement date = webBrowser1.Document.GetElementById("txtReceiptCreadDate_dateInput");
            HtmlElement button = webBrowser1.Document.GetElementById("btnSearch");
            string Text = monthCalendar1.SelectionStart.ToString("yyyy-MM-dd-00-00-00");
            //date.SetAttribute("value", "2013-03-19-00-00-00");
            date.SetAttribute("value", Text);
            button.InvokeMember("Click");
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
